package three

object func {
  def addOne(list: List[Int]): List[Int] = list.map(_ + 1)

  def filterEven(list: List[Int]): List[Int] = list.filter(_ % 2 == 0)

  def mapReduce(list: List[Int])(mapFunc: Int => Int)(reduceFunc: (Int, Int) => Int): Int = {
    list.map(mapFunc).reduce(reduceFunc)
  }

  def main(args: Array[String]): Unit = {
    val list = List(1,2,3,4,5,6,7,8,9,10)

    val addOneList = addOne(list)
    println(addOneList)

    val evenList = filterEven(list)
    println(evenList)

    val sum = mapReduce(list)(x => x * 2)(_+_)
    println(sum)
  }

}


